Skip to content

fix(parser): resolve custom-language names via configurable name_field (#691) - #702

Closed
anusbutt wants to merge 1 commit into
tirth8205:mainfrom
anusbutt:fix/generic-walker-name-fields
Closed

fix(parser): resolve custom-language names via configurable name_field (#691)#702
anusbutt wants to merge 1 commit into
tirth8205:mainfrom
anusbutt:fix/generic-walker-name-fields

Conversation

@anusbutt

Copy link
Copy Markdown
Contributor

Linked issue

Closes #691

What & why

The generic walker's name heuristic only checked an identifier-like child or a
field literally named name, so common BibTeX/LaTeX/Markdown node shapes were
extracted unnamed and silently dropped (losing the node and all its edges).

Adds an optional name_field key to .code-review-graph/languages.toml
(string or ordered list). For custom languages only, each candidate is resolved
field-first across all candidates, then by descendant node type, then descended
to a cleaned text leaf. Two-pass ordering makes precise fields win over a
broader type match (e.g. LaTeX \newcommand resolves via declaration, not the
text node in its body). Anchoring on configured candidates avoids returning
unrelated inner identifiers (e.g. BibTeX field labels title/author).
Built-in language extraction is byte-for-byte unchanged.

How it was tested

uv run pytest tests/test_custom_languages.py -q   # 31 passed
uv run pytest tests/test_parser.py tests/test_multilang.py -q  # 516 passed, no regressions
uv run ruff check code_review_graph/              # clean
uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional  # clean
Full suite: 1972 passed / 5 skipped / 2 xpassed. One unrelated failure
(test_mcp_stdio_shutdown) is pre-existing — it fails identically on a clean
tree (a 20s MCP-server-startup timeout), not touched by this change.

Checklist

- [x] Tests added for new functionality
- [x] All tests pass (except one pre-existing, unrelated MCP-stdio-shutdown timeout)
- [x] Linting passes
- [x] Type checking passes
- [x] Lines are at most 100 characters
- [x] Docs updated (docs/CUSTOM_LANGUAGES.md)

🤖 Generated with Claude Code (https://claude.com/claude-code)

tirth8205#691)

The generic walker only found a definition's name from an identifier-like
child or a field literally named "name", so BibTeX/LaTeX/Markdown nodes whose
name lives in a differently named or nested field were extracted unnamed and
silently dropped.

Add an optional `name_field` (string or ordered list) to languages.toml.
For custom languages only, resolve each candidate field-first across all
candidates, then by descendant node type, then descend to a clean text leaf.
Built-in language extraction is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tirth8205

Copy link
Copy Markdown
Owner

The 31 focused tests pass, but the configured name_field is not authoritative as described. _get_name accepts a generic direct-child identifier before it consults the configured field, so an unrelated identifier can still win. Please resolve the configured name_field first (or document different precedence) and add a fixture containing both an unrelated direct identifier and the configured field.

tirth8205 added a commit that referenced this pull request Jul 25, 2026
Integrates contributor PR #702 with its author commit preserved, resolves the current-main conflict, and adds a RED-to-GREEN precedence regression. Validation: 579 affected tests, Ruff, diff checks, and a clean 242-file full graph build.
@tirth8205

Copy link
Copy Markdown
Owner

Integrated through #736, merged as 805c4c6. Your contributor-authored commit is preserved in the merge history. The integration resolves the current-main parser conflict, makes configured name_field precedence authoritative, and adds the missing end-to-end competing-identifier regression. Final validation: 579 affected tests passed, Ruff/diff checks passed, and a full 242-file graph build completed cleanly. Closing this original PR as incorporated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic walker's name-field heuristic misses common LaTeX/BibTeX/Markdown node shapes

2 participants